class Axios {
    constructor() {

    }

    request(config) {
        return new Promise((resolve, reject) => {
           const { url = '', method = 'get', data= {}} = config
            // 发请求
            const xhr = new XMLHttpRequest()
            xhr.open(method, url, data)
            xhr.onload = function() {
                console.log(xhr.responseText); // 响应回来的数据
                resolve(xhr.responseText)
            } 
            xhr.send(data)
        })
    }
}


function CreateAxiosFn() {
    let axios = new Axios()
    let req = axios.request.bind(axios) // fn
    return req
}

let axios =  CreateAxiosFn()